import { App, PluginSettingTab, Setting } from 'obsidian';
import AbitUseful from './main';

export class AbitUsefulSettingTab extends PluginSettingTab {
	plugin: AbitUseful;

	constructor(app: App, plugin: AbitUseful) {
		super(app, plugin);
		this.plugin = plugin;
	}

	display(): void {
		const { containerEl } = this;

		containerEl.empty();

		containerEl.createEl('h2', { text: '笔记归集插件设置' });

		new Setting(containerEl)
			.setName('笔记导出目录')
			.setDesc('用于将笔记文件放在指定目录，方便归集笔记的附件，方便导出')
			.addText(text => text.setPlaceholder('目录名称')
				.setValue(this.plugin.settings.exportNotesFolder)
				.onChange(async (value) => {
					this.plugin.settings.exportNotesFolder = value;
					await this.plugin.saveSettings();
				}));

		new Setting(containerEl)
			.setName('导出是否删除原笔记及附件')
			.setDesc('勾选后，导出时会删除原笔记文件')
			.addToggle(toggle => toggle.setValue(this.plugin.settings.deleteOriginNote)
				.onChange(async (value) => {
					this.plugin.settings.deleteOriginNote = value;
					await this.plugin.saveSettings();
				}));
		new Setting(containerEl)
			.setName('一致性的结果文件名称')
			.setDesc('检查所有笔记附件一致性的结果文件名称')
			.addText(text => text.setPlaceholder('all-note-attachment-check-result.md')
				.setValue(this.plugin.settings.allNoteAttachmentResultFile)
				.onChange(async (value) => {
					this.plugin.settings.allNoteAttachmentResultFile = value;
					await this.plugin.saveSettings();
				}));
		new Setting(containerEl)
			.setName('入链笔记的结果文件名称')
			.setDesc('检查所有文件入链笔记的结果文件名称')
			.addText(text => text.setPlaceholder('all-file-inlink-notes.md')
				.setValue(this.plugin.settings.allInlinkNotesResultFile)
				.onChange(async (value) => {
					this.plugin.settings.allInlinkNotesResultFile = value;
					await this.plugin.saveSettings();
				}));
	}
}
